<?php
// 数据库连接配置  
$servername = "localhost";
$username = "bay";
$password = "bay618618";
$dbname = "bay_iot";

// 创建连接  
$conn = new mysqli($servername, $username, $password, $dbname);

// 检查连接  
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}

// 处理注册请求  
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST["username"];
    $password = $_POST["password"];
    $email = $_POST["email"];

    // 对密码进行哈希处理  
    $hashedPassword = password_hash($password, PASSWORD_DEFAULT);

    // 插入用户信息到数据库  
    $sql = "INSERT INTO user_table (username, password, email) VALUES ('$username', '$hashedPassword', '$email')";

    if ($conn->query($sql) === TRUE) {
        echo "注册成功";
    } else {
        echo "注册失败: " . $conn->error;
    }

    $conn->close();
}
?>